package com.example.ad_project;

import java.util.Date;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.nus.iss.ad.model.OrderDetail;
import com.nus.iss.ad.model.Request;
import com.nus.iss.ad.utils.MyUtilities;

public class RequestAdapter extends ArrayAdapter<Request> {
	 private Context context;
		private Request[] values;

		public  RequestAdapter(Context context, Request[] values) {
		   super(context, R.layout.approve_request_row, values);
		   this.context = context;
		   this.values = values;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
	        View v=convertView;
	        if (convertView == null) {
	        	LayoutInflater inflater = ((Activity)context).getLayoutInflater();
	            v = inflater.inflate(R.layout.approve_request_row, null);
	        }
	        TextView tDate = (TextView)v.findViewById(R.id.tvDate);
	        TextView tName = (TextView)v.findViewById(R.id.tvEmpName);
	      
	        
	        Request req=values[position];
	        Date date=req.getRequestDate();
	        String name=req.getEmployee().getName();
	        
	        tDate.setText(MyUtilities.dateToString(date, "dd-MMM-yyyy"));
	        tName.setText(name);
	       
	        return v;
			
		}
}
